cmake_minimum_required(VERSION 3.16)

set(TARGET avalon)

project(${TARGET} LANGUAGES CXX)

# 启用位置无关代码
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# 头文件和动态库的路径
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/include/libevent)
link_directories(${CMAKE_SOURCE_DIR}/lib)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)

file(GLOB HEADER_FILES netbus.h provider.h deliver.h)

add_library(${TARGET} SHARED
    netbus.cpp
    netbus.h
    connect_pool.cpp
    connect_pool.h
    connecter.h
    connecter.cpp
    connect_handler.h
    connect_handler.cpp
    provider.h
    provider.cpp
    deliver.h
    deliver.cpp
)

set_property(TARGET ${TARGET} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${TARGET} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON)

target_link_libraries(${TARGET} amqpcpp spdlog pthread event)

foreach (HEADER_FILE ${HEADER_FILES})
    message(${HEADER_FILE})
    file(COPY ${HEADER_FILE} DESTINATION ${CMAKE_SOURCE_DIR}/include/${TARGET}/)
endforeach()
